<?php

namespace app\site\controller;

use app\common\exception\MiException;
use app\site\service\NoticeTplService;
use think\db\exception\DbException;

class NoticeTplController extends AController
{

    /**
     * @throws DbException
     * @throws MiException
     */
    public function index() {
        $where = [];
        $noticeType = $this->param('where.notice_type', 0);
        if ($noticeType) $where[] = ['notice_type', '=', $noticeType];

        $ser = NoticeTplService::instance()->setWhere($where);
        return $this->reqSer->setService($ser)->setPaginate()->getResponse();
    }

    /**
     * @throws MiException
     */
    public function edit(){
        $ser = NoticeTplService::instance();
        if (request()->isPost()){
            return $this->reqSer->setService($ser)->edit()->getResponse();
        }else{
            return $this->reqSer->setService($ser)->setFind()->getResponse();
        }
    }

}
